﻿#include "InstructionTurnTableSetLoad.h"

__SCRIPTINSTRUCTION_REGISTER(InstructionTurnTableSetLoad,ScriptInstruction::Instruction_TurnTable_SetLoad,&InstructionTurnTableSetLoad::fromByteArray1);

InstructionTurnTableSetLoad::InstructionTurnTableSetLoad()
{
  instructionFlag = Instruction_TurnTable_SetLoad;
}

InstructionTurnTableSetLoad::InstructionTurnTableSetLoad(InstructionTurnTableSetLoad const& instructionTurnTableSetLoad)
{
  *this=instructionTurnTableSetLoad;
}

InstructionTurnTableSetLoad& InstructionTurnTableSetLoad::operator=(InstructionTurnTableSetLoad const & instructionTurnTableSetLoad)
{
  *(ScriptInstruction*)this=instructionTurnTableSetLoad;
  loadMode=instructionTurnTableSetLoad.loadMode;
  return *this;
}

InstructionTurnTableSetLoad::~InstructionTurnTableSetLoad()
{}

QString InstructionTurnTableSetLoad::toString()
{
  return QStringLiteral("转台%1").arg(loadMode?"负载":"空载");
}

QByteArray InstructionTurnTableSetLoad::toByteArray()
{
  return QByteArray().append((char*)&loadMode,sizeof (loadMode));
}

InstructionTurnTableSetLoad* InstructionTurnTableSetLoad::clone()
{
  return new InstructionTurnTableSetLoad(*this);
}

ScriptInstruction* InstructionTurnTableSetLoad::fromByteArray1(char * const src, int size, int * offset)
{
  if((size-*offset)<byteArraySize)
    {
      return Q_NULLPTR;
    }
  InstructionTurnTableSetLoad* instructionTurnTableSetLoad=new InstructionTurnTableSetLoad();
  instructionTurnTableSetLoad->setLoadMode(*(bool*)(src+*offset));
  offset+=sizeof (loadMode);
  return instructionTurnTableSetLoad;
}

bool InstructionTurnTableSetLoad::getLoadMode()
{
  return loadMode;
}

InstructionTurnTableSetLoad* InstructionTurnTableSetLoad::setLoadMode(bool loadMode)
{
  this->loadMode=loadMode;
  return this;
}
